package com.itheima.exception;

import com.itheima.entity.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author ：yuanjian
 * @date ：Created in 2020/11/15 17:08
 * @description： 全局异常处理
 */
@RestControllerAdvice
public class GlobalExceptionInvoker {

    @ExceptionHandler
    public Result handleException(Exception ex) {
        ex.printStackTrace();
        String _message = ex.getMessage();
        String msg = _message.length() > 200 ? _message.substring(0, 200) : _message;
        return new Result(false, msg);
    }
}
